package org.example.udemo3;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//@RestController
////@RequestMapping("/p1")
//public class PropertiesController {
//    @Value("${k}")
//    private String k;
//
//            @RequestMapping("/v1")
//    public String key(String k){
//        System.out.println("注入后的k值为: " + k);
//        if (k == null) {
//            System.out.println("k的值为null");
//        }
//        return "读取到properties文件中的mykey1的值: "+ k;
//    }
//
//}

@RestController
public class PropertiesController {
    @Value("${k}")
    private String k;

    @RequestMapping("/v1")
    public String key(String input) {
        System.out.println("注入后的k值为: " + k);
        if (k == null) {
            System.out.println("k的值为null");
        }
        return "读取到properties文件中的值: " + k;
    }
}